<template>
  <el-card class="dashboard-card" shadow="hover" @click="$emit('click')">
    <div class="card-content">
      <div class="card-icon" :style="{ backgroundColor: color }">
        <el-icon :size="24" color="white">
          <component :is="icon" />
        </el-icon>
      </div>
      
      <div class="card-info">
        <div class="card-title">{{ title }}</div>
        <div class="card-value">
          {{ value }}
          <span v-if="unit" class="unit">{{ unit }}</span>
        </div>
        
        <div v-if="trend" class="card-trend">
          <el-icon :class="trend">
            <ArrowUp v-if="trend === 'up'" />
            <ArrowDown v-else-if="trend === 'down'" />
            <Minus v-else />
          </el-icon>
          <span v-if="trendValue" class="trend-value">{{ trendValue }}</span>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script setup lang="ts">
import type { DashboardCardProps } from '@/types'

defineProps<DashboardCardProps>()
defineEmits<{
  click: []
}>()
</script>

<style scoped>
.dashboard-card {
  height: 120px;
  border-radius: 8px;
  transition: all 0.3s;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card-content {
  display: flex;
  align-items: center;
  height: 100%;
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  flex-shrink: 0;
}

.card-info {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: var(--font-subtitle);
  color: #666;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-value {
  font-size: var(--font-size-18);
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit {
  font-size: var(--font-subtitle);
  font-weight: normal;
  color: #999;
  margin-left: 4px;
}

.card-trend {
  display: flex;
  align-items: center;
  font-size: var(--font-caption);
}

.card-trend.up {
  color: #67C23A;
}

.card-trend.down {
  color: #F56C6C;
}

.card-trend.stable {
  color: #909399;
}

.trend-value {
  margin-left: 4px;
}
</style> 